#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

class segment_tree {
	int size = 0;
	vector<long> length;
	vector<long> cover;
	vector<int> times;
	map<int, int> mp;

	vector<vector<int>> &rec;
	vector<vector<int>> line;
	vector<int> ysort;

	void up(int i)
	{
		if (times[i] > 0) {
			cover[i] = length[i];
		} else {
			cover[i] = cover[i << 1] + cover[i << 1 | 1];
		}
	}

	void build(int l, int r, int i)
	{
		if (l == r) {
			length[i] = ysort[l + 1] - ysort[l];
		} else {
			int mid = (l + r) >> 1;
			build(l, mid, i << 1);
			build(mid + 1, r, i << 1 | 1);
			length[i] = ysort[r + 1] - ysort[l];
			up(i);
		}
	}

	void update(int jobl, int jobr, int v, int l, int r, int i)
	{
		if (jobl <= l && r <= jobr) {
			times[i] += v;
			if (times[i] > 0) {
				cover[i] = length[i];
			} else {
				if (l == r) {
					cover[i] = 0;
				} else {
					cover[i] = cover[i << 1] + cover[i << 1 | 1];
				}
			}
		} else {
			int mid = (l + r) >> 1;
			if (jobl <= mid) {
				update(jobl, jobr, v, l, mid, i << 1);
			}
			if (mid < jobr) {
				update(jobl, jobr, v, mid + 1, r, i << 1 | 1);
			}
			up(i);
		}
	}

    public:
	segment_tree(vector<vector<int>> &rectangle) : rec(rectangle)
	{
		ysort.push_back(-1);
		for (int i = 0; i < rec.size(); i++) {
			ysort.push_back(rec[i][1]);
			ysort.push_back(rec[i][3]);
			line.push_back({ rec[i][0], rec[i][1], rec[i][3], 1 });
			line.push_back({ rec[i][2], rec[i][1], rec[i][3], -1 });
		}
		sort(line.begin(), line.end());
		sort(ysort.begin(), ysort.end());
		ysort.erase(unique(ysort.begin(), ysort.end()), ysort.end());
		size = ysort.size() - 1;
		for (int i = 1; i < ysort.size(); i++) {
			mp[ysort[i]] = i;
		}
		ysort.push_back(ysort.back());

		length.resize(size << 2, 0);
		cover.resize(size << 2, 0);
		times.resize(size << 2, 0);

		build(1, size, 1);
	}

	long cal()
	{
		long ans = 0;
		for (int i = 0, pre = 0; i < line.size(); i++) {
			ans += cover[1] * (line[i][0] - pre);
			pre = line[i][0];
			update(mp[line[i][1]], mp[line[i][2]] - 1, line[i][3], 1, size, 1);
		}
		return ans;
	}
};

int main()
{
	//freopen("P5490_1.in", "r", stdin);
	int n = 0;
	cin >> n;
	vector<vector<int>> rectang;
	for (int i = 0, x1, y1, x2, y2; i < n; i++) {
		cin >> x1 >> y1 >> x2 >> y2;
		rectang.push_back({ x1, y1, x2, y2 });
	}
	segment_tree sgt(rectang);
	cout << sgt.cal() << endl;
	return 0;
}
/*
3
10 10 50 40
30 50 80 70
40 30 70 60
*/